﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TemplateAddIn
{
    public partial class VariableCreationUI : Form
    {
        string selectedText;

        public VariableCreationUI(string pSelectedText)
        {
            InitializeComponent();

            selectedText = pSelectedText;
        }

        private void btnCreate_Click(object sender, EventArgs e)
        {
            Variable newVar = null;

            switch (cobVariableType.SelectedIndex)
            {
                case 0:
                    newVar = new TextVariable(ttbVariableName.Text, (selectedText == null) ? "" : selectedText);
                    break;

                case 1:
                    newVar = new ImageVariable(ttbVariableName.Text);
                    break;
            }

            Globals.ThisAddIn.VarList.Add(newVar);

            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void VariableCreationUI_Load(object sender, EventArgs e)
        {
            cobVariableType.SelectedIndex = 0;
        }
    }
}
